/*
 * Edge.h
 *
 *  Created on: Nov 24, 2009
 *      Author: abhishek
 */

#ifndef EDGE_H_
#define EDGE_H_

#include "Headers.h"

class Edge {
public:
	Edge(int node1, int node2){ node1_ = node1 ; node2_ = node2 ; key_ = Utils::makeKey(node1, node2); numBadCycles_ = 0; numGoodCycles_ = 0 ;}
	Edge(int node1, int node2, string key){ node1_ = node1 ; node2_ = node2 ; key_ = key;numBadCycles_ = 0; numGoodCycles_ = 0 ;}
	virtual ~Edge(){}

//	void numBadMinusGoodCyclesIs(int value){ numBadMinusGoodCycles_ = value; }
//	int numBadMinusGoodCycles() const {return numBadMinusGoodCycles_;}

	int numBadCycles(){return numBadCycles_; }
	int numGoodCycles(){return numGoodCycles_;}
	int numBadMinusGoodCycles() const {return numBadCycles_ - numGoodCycles_ ; }

	void numBadCyclesInc(int value){numBadCycles_ = numBadCycles_ + value ; }
	void numBadCyclesDec(int value){numBadCycles_ = numBadCycles_ - value ; }
	void numGoodCyclesInc(int value){numGoodCycles_ = numGoodCycles_ + value ; }
	void numGoodCyclesDec(int value){numGoodCycles_ = numGoodCycles_ - value ; }

	set<string> allEdgesInCycles(){return edgesInCycles_; }
	void allEdgesInCyclesAdd(string key){ edgesInCycles_.insert(key);}
	void allEdgesInCyclesDel(string key){ edgesInCycles_.erase(key);}

	int nodeFirst(){return node1_ ;}
	int nodeSecond(){return node2_ ;}
	string key(){return key_ ; }

private:
	int node1_ ;
	int node2_ ;
	string key_ ;
	int numBadCycles_ ;
	int numGoodCycles_ ;
	set<string> edgesInCycles_ ;
//	int numBadMinusGoodCycles_ ;
};

class Comparator
{

public:
  Comparator(){}

  // Greater than..
  bool operator() (const Edge* lhs, const Edge* rhs) const
  {

	 if (lhs->numBadMinusGoodCycles() < rhs->numBadMinusGoodCycles() )
		 return true ;
	 return false;
  }
};

#endif /* EDGE_H_ */
